<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <%@ include file="/WEB-INF/views/include/head.jsp"%> 
        <link rel="stylesheet" href="${ctxStatic}/css/list.css">
            <script type="text/javascript">
                $(document).ready(function(){
                    $("#materialTypeCd,#materialUseType").select2();
                   });
               //重置
               function clean(){
                   $("input").val("");
                   $('#materialTypeCd,#materialUseType').val('');
                   $("#materialTypeCd,#materialUseType").select2();
                   $("#searchForm").submit();
               }
            </script> 
    </head>
    <body>
        <form  id="searchForm" action="${ctx}/material/mywarehouse/list" method="post">
        <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
        <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
        <c:set value="<%=ResourcesUtil.getConfig(\"material_Category\")%>" var="materialCategory" />
        <c:set value="<%=ResourcesUtil.getConfig(\"material_UseType\")%>" var="useType" />
            <div class="listSearchBox clearfix">
                <div class="searchLeft clearfix">
                    <div class="searchSm clearfix">
                        <!-- 业务类别 -->
                        <p class="searchTxt"><spring:message code="myMaterial_businessType"/></p>
                        <div class="searchInp">
                            <select  style="width:110px" id="materialUseType" name="materialUseType" >
                                <option value=""><spring:message code="myMaterial_pleaseChoosed"/></option>
                                <c:forEach items="${fns:getDictList(useType)}"   var="type">
                                    <option  <c:if test="${fn:split(material.materialUseType,'-')[1] eq type.itemValue}">selected="selected"</c:if> value="${type.itemCode}-${type.itemValue}" > 
                                        ${type.itemName}
                                    </option>
                                </c:forEach>
                            </select>
                        </div>
                    </div>
                    <div class="searchSm clearfix">
                        <!-- 物料类别 -->
                        <p class="searchTxt"><spring:message code="myWarehouse_type"/></p>
                        <div class="searchInp">
                            <select class="sex" id="materialTypeCd" name="materialTypeCd" style="width:110px">
                                <option value=""><spring:message code="myWarehouse_pleaseChoosed"/></option>
                                <c:forEach items="${fns:getDictList(materialCategory)}"   var="category">
                                    <option  <c:if test="${fn:split(material.materialTypeCd,'-')[1] eq category.itemValue}">selected="selected"</c:if> value="${category.itemCode}-${category.itemValue}" > 
                                        ${category.itemName}
                                    </option>
                                </c:forEach>
                            </select>
                        </div>
                    </div>
                    <div class="searchSm clearfix">
                        <!-- 物料名称 -->
                        <p class="searchTxt"><spring:message code="myWarehouse_name"/></p>
                        <div class="searchInp">
                            <input type="text"  id="materialNameCn"  name="materialNameCn"  value="${material.materialNameCn}" >
                        </div>
                    </div>
                    <div class="searchSm clearfix">
                        <!-- 物料颜色 -->
                        <p class="searchTxt"><spring:message code="myWarehouse_color"/></p>
                        <div class="searchInp">
                            <input type="text"  id="materialColor"  name="materialColor"  value="${material.materialColor}" >
                        </div>
                    </div>
                    <div class="searchSm clearfix">
                        <!-- 物料成分 -->
                        <p class="searchTxt"><spring:message code="myWarehouse_composition"/></p>
                        <div class="searchInp">
                            <input type="text"  id="materialComposition"  name="materialComposition"  value="${material.materialComposition}" >
                        </div>
                    </div>
                </div>
                <div class="searchRight">
                    <!-- 重置 -->
                    <button type="button" class="btn-js" onclick="clean();"><spring:message code="myWarehouse_reset"/></button>
                    <!-- 查询 -->
                    <button type="button" class="btn-js" onclick="return page();"><spring:message code="commom_check"/></button>
                </div>
            </div>
        </form>
        <div class="tableBox">
            <div class="tableBoxScroll tablePic">
                <div class="tabScroll">
                <table cellpadding="0">
                    <thead>
                    <tr>
                        <!-- 序号No. -->
                        <th><spring:message code="common_no"/></th>
                        <!-- 物料图片 -->
                        <th><spring:message code="myWarehouse_pic"/></th>
                        <!-- 编码/物料名称 -->
                        <th><spring:message code="myWarehouse_name_code"/></th>
                        <!-- 业务类别 -->
                        <th><spring:message code="myMaterial_businessType"/></th>
                        <!-- 物料类别 -->
                        <th><spring:message code="myWarehouse_type"/></th>
                        <!-- 物料颜色 -->
                        <th><spring:message code="myWarehouse_color"/></th>
                        <!-- 物料成分 -->
                        <th><spring:message code="myWarehouse_composition"/></th>
                        <!-- 物料规格 -->
                        <th><spring:message code="myWarehouse_spec"/></th>
                        <!-- 季节年份 -->
                        <th><spring:message code="myWarehouse_season_year"/></th>
                        <shiro:hasPermission name="sys:admin:view">
                        <!-- 预警数量 -->
                        <th><spring:message code="myWarehouse_alert_quantity"/></th>
                        <!-- 库存数量 -->
                        <th><spring:message code="myWarehouse_inventory_quantity"/></th>
                        </shiro:hasPermission>
                        <!-- 出厂价 -->
                        <th><spring:message code="myWarehouse_factory_price"/></th>
                        <!-- 售价 -->
                        <th><spring:message code="myWarehouse_selling_price"/></th>
                        <!-- 描述 -->
                        <th><spring:message code="myWarehouse_remarks"/></th>
                    </tr>
                    </thead>
                    <c:if test="${not empty page.list}" >
                        <tbody>
                            <c:forEach items="${page.list}" var="material" varStatus="status">
                                <tr>
                                    <td>
                                        <p>${(page.pageNo-1)*page.pageSize + status.index+1}</p>
                                    </td>
                                    <td>
                                        <c:if test="${not empty material.filePath}">
                                           <img src="${material.filePath}" class="tableImg">
                                           <img src="${material.filePath}" class="posImg">
                                        </c:if>
                                        <c:if test="${empty material.filePath}">
                                           <img src="${ctxStatic}/images/pic-none.jpg" class="tableImg">
                                        </c:if>
                                    </td>
                                    <td>
                                        <p style="line-height: 18px;"  data-toggle="tooltip" title="${material.materialCode}  ${material.materialNameCn}">${material.materialCode}<br>${material.materialNameCn}</p>
                                    </td>
                                    <td>
                                        <p data-toggle="tooltip" title="${fns:getDictName(material.materialUseType)}">${fns:getDictName(material.materialUseType)}</p>
                                    </td>
                                    <td>
                                        <p data-toggle="tooltip" title="${fns:getDictName(material.materialTypeCd)}">${fns:getDictName(material.materialTypeCd)}</p>
                                    </td>
                                    <td>
                                        <p data-toggle="tooltip" title="${material.materialColor}">${material.materialColor}</p>
                                    </td>
                                    <td>
                                        <p data-toggle="tooltip" title="${material.materialComposition}">${material.materialComposition}</p>
                                    </td>
                                    <td>
                                        <p data-toggle="tooltip" title="${material.materialSpec} ${fns:getDictName(material.materialUnitCd)}">${material.materialSpec} ${fns:getDictName(material.materialUnitCd)}</p>
                                    </td>
                                    <td>
                                        <p data-toggle="tooltip" title="${material.materialYear} ${fns:getDictName(material.materialSeason)}">${material.materialYear} ${fns:getDictName(material.materialSeason)}</p>
                                    </td>
                                    <shiro:hasPermission name="sys:admin:view">
                                    <td>
                                        <p class="show" <shiro:hasPermission name="material:mywarehouse:edit">onclick="popup('700px','350px','${ctx}/material/mywarehouse/formAlert?id=${material.id}')"</shiro:hasPermission>><fmt:formatNumber value="${material.materialAlert.materialAlertQuantity}" pattern="#,##0.00#"/>&nbsp;${fns:getDictName(material.materialUnitCd)}</p>
                                    </td> 
                                    <td>
                                        <p class="show" <shiro:hasPermission name="material:mywarehouse:edit">onclick="popup('700px','350px','${ctx}/material/mywarehouse/formInventory?id=${material.id}')"</shiro:hasPermission>><fmt:formatNumber value="${material.inventoryMaterial.materialQuantity}" pattern="#,##0.00#"/>&nbsp;${fns:getDictName(material.materialUnitCd)}</p>
                                    </td>
                                    </shiro:hasPermission>
                                    <td>
                                        <p data-toggle="tooltip" title="<fmt:formatNumber value="${material.purchasePrice}" pattern="#,#00.00#"/>"><fmt:formatNumber value="${material.purchasePrice}" pattern="#,##0.00#"/></p>
                                    </td>
                                    <td>
                                        <p <shiro:hasPermission name="material:mywarehouse:edit">
	                                           <c:if test="${fns:getUser().isAdmin()  eq false }" > 
	                                               class="show"    onclick="popup('700px','350px','${ctx}/material/mywarehouse/formPrice?id=${material.id}')"
	                                           </c:if>
                                           </shiro:hasPermission>>
                                              <fmt:formatNumber value="${material.materialPrice.materialSalePrice}" pattern="#,##0.00#"/>
                                        </p>
                                    </td>
                                    <td>
                                        <p data-toggle="tooltip" title="${material.remarks}">${material.remarks}</p>
                                    </td>
                                </tr>
                            </c:forEach>
                        </tbody>
                    </c:if>
                </table>
                 <c:if test="${empty page.list}" >
                    <div class="tableNone">
                        <img src="${ctxStatic}/images/icon-03.png" height="20"> <spring:message code="There_is_no_data"/>
                    </div>
                </c:if>
                </div>
            </div>
            <%@ include file="/WEB-INF/views/include/page.jsp"%>
        </div>
        <script src="${ctxStatic}/layer/layerStyle.js"></script>
        <script>
         var listH = $(':root').css('height');
            $(window.parent.$("#mainFrame").css('height',listH));
            window.onload = function(){
                var theadW = $('.tabScroll thead').width()
                var theadTh = $('.tabScroll thead tr th').length
                $('.tabScroll thead tr th').width(theadW/theadTh)
                $('.tabScroll tbody tr:first-child td').each(function(){
                    var indexNum = $(this).index()
                    var tdWidth = $('.tabScroll tbody tr:first-child td').eq(indexNum).css('width')
                    $('.tabScroll thead tr th').eq(indexNum).width(tdWidth);
                })

            }
        </script>
</body>
</html>